package com.hl.card.modular.packBack.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.hl.card.common.controller.BaseController;
import com.hl.card.common.persistence.model.Recharge;
import com.hl.card.modular.pack.service.RechargeService;

@Controller
@RequestMapping("/exchangeList")
public class ExchangeController extends BaseController {

    private String PREFIX = "/packback/exchangeInfo/";
    private final String EXTRA = "EXCHANGE";
    private final String INDEX_PAGE = "/exchangeList";
    private final String LIST_PAGE = "exchangeList.html";
    
    @Autowired
    private RechargeService rechargeService;
    @RequestMapping("")
    public String index(HttpServletRequest request, ModelMap model){
    	
    	String toPage=INDEX_PAGE;
        model.put("notify", "兑换通证审核操作");
    	String page =baseCheckAccess(request, toPage, "/exchangeList", model);
//    	String page = toPage;
    	if (!toPage.equals(page)) {
    		return page;
		}
    	return PREFIX+LIST_PAGE;
    }

    
    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(Recharge recharge,Integer pageSize, Integer pageIndex) {
    	recharge.setExtra(EXTRA);
    	Page<Recharge> dPage = rechargeService.selectMultiCondition(recharge);
        Map<String, Object> jsonMap = new HashMap<String, Object>();
		jsonMap.put("total", dPage.getTotal());
		jsonMap.put("rows", dPage.getRecords());
        
        return jsonMap;
    }


   
}
